package receiver.edu.unisannio;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class ServerBroadcastReceiver extends BroadcastReceiver {
final private static String ACTION= "org.unisannio.PolitePingPong";
	
	
	@Override
	public void onReceive(Context context, Intent intent) {

		Bundle results = getResultExtras(true); //questo true ci permette di passare i parametri ai successivi BroadcastReceiver, quindi al chiamante
        String nostraStringa = intent.getExtras().getString("stringaInviata");
        Toast toast=Toast.makeText(context, "ServerReceiver - Stringa ricevuta: "+nostraStringa, Toast.LENGTH_LONG);
		toast.show();
//		results.putString("risposta", "Buongiornoooooo!");
		String[] array=results.getStringArray("risposte");
		if (array==null) array=new String[0];
		int lun=array.length;
		String[] newArray = new String[lun+1];
		int i;
		for (i=0; i<lun; i++){
			newArray[i]=array[i];
		}
		newArray[i]="Buongiornoooooo";
			
		results.putStringArray("risposte", newArray);
		
	}

}
